<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Cheetah Software: rt_sbus.h File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Cheetah Software
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d1/d95/rt__sbus_8h.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">rt_sbus.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;stdint.h&gt;</code><br />
</div><div class="textblock"><div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="../../closed.png" alt="+"/> Include dependency graph for rt_sbus.h:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../dd/d66/rt__sbus_8h__incl.png" border="0" usemap="#rt__sbus_8h" alt=""/></div>
<map name="rt__sbus_8h" id="rt__sbus_8h">
</map>
</div>
</div><div class="textblock"><div id="dynsection-1" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-1-trigger" src="../../closed.png" alt="+"/> This graph shows which files directly or indirectly include this file:</div>
<div id="dynsection-1-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-1-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d2/d1a/rt__sbus_8h__dep__incl.png" border="0" usemap="#rt__sbus_8hdep" alt=""/></div>
<map name="rt__sbus_8hdep" id="rt__sbus_8hdep">
</map>
</div>
</div>
<p><a href="../../d1/d95/rt__sbus_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a0e901a1bce4a485f80a310854215905c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d95/rt__sbus_8h.html#a0e901a1bce4a485f80a310854215905c">unpack_sbus_data</a> (uint8_t sbus_data[], uint16_t *<a class="el" href="../../d2/dad/rt__sbus_8cpp.html#a45701f35ad10342d895fc3637c8fc227">channels</a>)</td></tr>
<tr class="separator:a0e901a1bce4a485f80a310854215905c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9e7b14a9fd5b1e62a38337c44d95ff04"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d95/rt__sbus_8h.html#a9e7b14a9fd5b1e62a38337c44d95ff04">read_sbus_data</a> (int port, uint8_t *sbus_data)</td></tr>
<tr class="separator:a9e7b14a9fd5b1e62a38337c44d95ff04"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a556abff30497289e33d971c6069c455c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d95/rt__sbus_8h.html#a556abff30497289e33d971c6069c455c">read_sbus_channel</a> (int channel)</td></tr>
<tr class="separator:a556abff30497289e33d971c6069c455c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab44d038981e16325d8aec78b2c1011bf"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d95/rt__sbus_8h.html#ab44d038981e16325d8aec78b2c1011bf">receive_sbus</a> (int port)</td></tr>
<tr class="separator:ab44d038981e16325d8aec78b2c1011bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1f8bbf50154d9822f453616920c26127"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d95/rt__sbus_8h.html#a1f8bbf50154d9822f453616920c26127">init_sbus</a> (int is_simulator)</td></tr>
<tr class="separator:a1f8bbf50154d9822f453616920c26127"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a1f8bbf50154d9822f453616920c26127"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int init_sbus </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>is_simulator</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00119">119</a> of file <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html">rt_sbus.cpp</a>.</p>

<p>References <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00031">K_SBUS_PORT_MC</a>, <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00029">K_SBUS_PORT_SIM</a>, <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">sbus_data_m</a>, and <a class="el" href="../../d3/d28/rt__serial_8cpp_source.html#l00040">set_interface_attribs_custom_baud()</a>.</p>
<div class="fragment"><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;                                {</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;  <span class="comment">// char *port1;</span></div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;  std::string port1;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;  <span class="keywordflow">if</span> (is_simulator) {</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    port1 = <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#ad057608898e25926f2e9fe39c858b7ba">K_SBUS_PORT_SIM</a>;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    port1 = <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#acf3b62f76492526c22f2ecd63c544895">K_SBUS_PORT_MC</a>;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;  }</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;  <span class="keywordflow">if</span> (pthread_mutex_init(&amp;<a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a>, NULL) != 0) {</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    printf(<span class="stringliteral">&quot;Failed to initialize sbus data mutex.\n&quot;</span>);</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  }</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  <span class="keywordtype">int</span> fd1 = open(port1.c_str(), O_RDWR | O_NOCTTY | O_SYNC);</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  <span class="keywordflow">if</span> (fd1 &lt; 0) {</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    printf(<span class="stringliteral">&quot;Error opening %s: %s\n&quot;</span>, port1.c_str(), strerror(errno));</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    <a class="code" href="../../de/d23/rt__serial_8h.html#adc24908fd964d1eeb3b4dcd058a06e0d">set_interface_attribs_custom_baud</a>(fd1, 100000, 0, 0);</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;  }</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;  <span class="keywordflow">return</span> fd1;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;}</div><div class="ttc" id="rt__sbus_8cpp_html_ad057608898e25926f2e9fe39c858b7ba"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#ad057608898e25926f2e9fe39c858b7ba">K_SBUS_PORT_SIM</a></div><div class="ttdeci">#define K_SBUS_PORT_SIM</div><div class="ttdoc">Name of SBUS serial port in simulator. </div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00029">rt_sbus.cpp:29</a></div></div>
<div class="ttc" id="rt__serial_8h_html_adc24908fd964d1eeb3b4dcd058a06e0d"><div class="ttname"><a href="../../de/d23/rt__serial_8h.html#adc24908fd964d1eeb3b4dcd058a06e0d">set_interface_attribs_custom_baud</a></div><div class="ttdeci">int set_interface_attribs_custom_baud(int fd, int speed, int parity, int port)</div><div class="ttdoc">Configure serial port. </div><div class="ttdef"><b>Definition:</b> <a href="../../d3/d28/rt__serial_8cpp_source.html#l00040">rt_serial.cpp:40</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_a6f3dc153fb3589ec1de06f497f9c24fd"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a></div><div class="ttdeci">pthread_mutex_t sbus_data_m</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">rt_sbus.cpp:23</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_acf3b62f76492526c22f2ecd63c544895"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#acf3b62f76492526c22f2ecd63c544895">K_SBUS_PORT_MC</a></div><div class="ttdeci">#define K_SBUS_PORT_MC</div><div class="ttdoc">Name of SBUS serial port on the mini cheetah. </div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00031">rt_sbus.cpp:31</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-2" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-2-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-2-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-2-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_cgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_cgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_cgraph" id="d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-3" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-3-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-3-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-3-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_icgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_icgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_icgraph" id="d1/d95/rt__sbus_8h_a1f8bbf50154d9822f453616920c26127_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a556abff30497289e33d971c6069c455c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int read_sbus_channel </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>channel</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00101">101</a> of file <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html">rt_sbus.cpp</a>.</p>

<p>References <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00026">channel_data</a>, and <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">sbus_data_m</a>.</p>
<div class="fragment"><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                                   {</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;  pthread_mutex_lock(&amp;<a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a>);</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;  <span class="keywordtype">int</span> value = <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a4e7ed72b0ccac4c7b9c209145ea4b01b">channel_data</a>[channel];</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;  pthread_mutex_unlock(&amp;<a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a>);</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;  <span class="keywordflow">return</span> value;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;}</div><div class="ttc" id="rt__sbus_8cpp_html_a6f3dc153fb3589ec1de06f497f9c24fd"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a></div><div class="ttdeci">pthread_mutex_t sbus_data_m</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">rt_sbus.cpp:23</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_a4e7ed72b0ccac4c7b9c209145ea4b01b"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a4e7ed72b0ccac4c7b9c209145ea4b01b">channel_data</a></div><div class="ttdeci">uint16_t channel_data[18]</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00026">rt_sbus.cpp:26</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-4" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-4-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-4-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-4-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_a556abff30497289e33d971c6069c455c_icgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_a556abff30497289e33d971c6069c455c_icgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_a556abff30497289e33d971c6069c455c_icgraph" id="d1/d95/rt__sbus_8h_a556abff30497289e33d971c6069c455c_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a9e7b14a9fd5b1e62a38337c44d95ff04"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int read_sbus_data </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>sbus_data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00076">76</a> of file <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html">rt_sbus.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                                                 {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  uint8_t packet_full = 0;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  uint8_t read_byte[1] = {0};</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keywordtype">int</span> timeout_counter = 0;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  <span class="comment">// int n = read(fd1, read_buff, sizeof(read_buff));</span></div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  <span class="keywordflow">while</span> ((!packet_full) &amp;&amp; (timeout_counter &lt; 50)) {</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    timeout_counter++;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="comment">// Read a byte //</span></div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordtype">int</span> n = read(port, read_byte, <span class="keyword">sizeof</span>(read_byte));</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    (void)n;</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    <span class="comment">// Shift the buffer //</span></div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 24; i++) {</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;      sbus_data[i] = sbus_data[i + 1];</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    }</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    sbus_data[24] = read_byte[0];</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <span class="comment">// Check for the correct start and stop bytes ///</span></div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordflow">if</span> ((sbus_data[0] == 15) &amp;&amp; (sbus_data[24] == 0)) {</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;      <span class="comment">// unpack_sbus_data(sbus_data_buff, channels);</span></div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;      packet_full = 1;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    }</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  }</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="keywordflow">return</span> packet_full;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;}</div></div><!-- fragment -->
<p><div id="dynsection-5" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-5-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-5-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-5-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_a9e7b14a9fd5b1e62a38337c44d95ff04_icgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_a9e7b14a9fd5b1e62a38337c44d95ff04_icgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_a9e7b14a9fd5b1e62a38337c44d95ff04_icgraph" id="d1/d95/rt__sbus_8h_a9e7b14a9fd5b1e62a38337c44d95ff04_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ab44d038981e16325d8aec78b2c1011bf"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int receive_sbus </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>port</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00108">108</a> of file <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html">rt_sbus.cpp</a>.</p>

<p>References <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00025">channels</a>, <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00076">read_sbus_data()</a>, and <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00033">unpack_sbus_data()</a>.</p>
<div class="fragment"><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;                           {</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  uint16_t read_buff[25] = {0};</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;  <span class="keywordtype">int</span> x = <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a9e7b14a9fd5b1e62a38337c44d95ff04">read_sbus_data</a>(port, (uint8_t *)read_buff);</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  <span class="keywordflow">if</span> (x) {</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#ae5c751d99f7c584b302ee953b66fbce1">unpack_sbus_data</a>((uint8_t *)read_buff, <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a45701f35ad10342d895fc3637c8fc227">channels</a>);</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    printf(<span class="stringliteral">&quot;SBUS tried read 50 bytes without seeing a packet\n&quot;</span>);</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;  }</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;  <span class="keywordflow">return</span> x;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;}</div><div class="ttc" id="rt__sbus_8cpp_html_ae5c751d99f7c584b302ee953b66fbce1"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#ae5c751d99f7c584b302ee953b66fbce1">unpack_sbus_data</a></div><div class="ttdeci">void unpack_sbus_data(uint8_t sbus_data[], uint16_t *channels_)</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00033">rt_sbus.cpp:33</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_a9e7b14a9fd5b1e62a38337c44d95ff04"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a9e7b14a9fd5b1e62a38337c44d95ff04">read_sbus_data</a></div><div class="ttdeci">int read_sbus_data(int port, uint8_t *sbus_data)</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00076">rt_sbus.cpp:76</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_a45701f35ad10342d895fc3637c8fc227"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a45701f35ad10342d895fc3637c8fc227">channels</a></div><div class="ttdeci">uint16_t channels[18]</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00025">rt_sbus.cpp:25</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-6" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-6-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-6-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-6-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_cgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_cgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_cgraph" id="d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-7" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-7-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-7-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-7-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_icgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_icgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_icgraph" id="d1/d95/rt__sbus_8h_ab44d038981e16325d8aec78b2c1011bf_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a0e901a1bce4a485f80a310854215905c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void unpack_sbus_data </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>sbus_data</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>channels</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00033">33</a> of file <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html">rt_sbus.cpp</a>.</p>

<p>References <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00026">channel_data</a>, and <a class="el" href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">sbus_data_m</a>.</p>
<div class="fragment"><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;                                                                {</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="keywordflow">if</span> ((sbus_data[0] == 0xF) &amp;&amp; (sbus_data[24] == 0x0)) {</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    channels_[0] = ((sbus_data[1]) | ((sbus_data[2] &amp; 0x7) &lt;&lt; 8));</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    channels_[1] = (sbus_data[2] &gt;&gt; 3) | ((sbus_data[3] &amp; 0x3F) &lt;&lt; 5);</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    channels_[2] = ((sbus_data[3] &amp; 0xC0) &gt;&gt; 6) | (sbus_data[4] &lt;&lt; 2) |</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;                   ((sbus_data[5] &amp; 0x1) &lt;&lt; 10);</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    channels_[3] = ((sbus_data[5] &amp; 0xFE) &gt;&gt; 1) | ((sbus_data[6] &amp; 0xF) &lt;&lt; 7);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    channels_[4] = ((sbus_data[6] &amp; 0xF0) &gt;&gt; 4) | ((sbus_data[7] &amp; 0x7F) &lt;&lt; 4);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    channels_[5] = ((sbus_data[7] &amp; 0x80) &gt;&gt; 7) | (sbus_data[8] &lt;&lt; 1) |</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;                   ((sbus_data[9] &amp; 0x3) &lt;&lt; 9);</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    channels_[6] = ((sbus_data[9] &amp; 0xFC) &gt;&gt; 2) | ((sbus_data[10] &amp; 0x1F) &lt;&lt; 6);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    channels_[7] = ((sbus_data[10] &amp; 0xE0) &gt;&gt; 5) | (sbus_data[11] &lt;&lt; 3);</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    channels_[8] = ((sbus_data[12]) | ((sbus_data[13] &amp; 0x7) &lt;&lt; 8));</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    channels_[9] = (sbus_data[13] &gt;&gt; 3) | ((sbus_data[14] &amp; 0x3F) &lt;&lt; 5);</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    channels_[10] = ((sbus_data[14] &amp; 0xC0) &gt;&gt; 6) | (sbus_data[15] &lt;&lt; 2) |</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;                    ((sbus_data[16] &amp; 0x1) &lt;&lt; 10);</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    channels_[11] =</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        ((sbus_data[16] &amp; 0xFE) &gt;&gt; 1) | ((sbus_data[17] &amp; 0xF) &lt;&lt; 7);</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    channels_[12] =</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        ((sbus_data[17] &amp; 0xF0) &gt;&gt; 4) | ((sbus_data[18] &amp; 0x7F) &lt;&lt; 4);</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    channels_[13] = ((sbus_data[18] &amp; 0x80) &gt;&gt; 7) | (sbus_data[19] &lt;&lt; 1) |</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;                    ((sbus_data[20] &amp; 0x3) &lt;&lt; 9);</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    channels_[14] =</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        ((sbus_data[20] &amp; 0xFC) &gt;&gt; 2) | ((sbus_data[21] &amp; 0x1F) &lt;&lt; 6);</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    channels_[15] = ((sbus_data[21] &amp; 0xE0) &gt;&gt; 5) | (sbus_data[22] &lt;&lt; 3);</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    channels_[16] = (sbus_data[23] &amp; 0x80) &gt;&gt; 7;</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    channels_[17] = (sbus_data[23] &amp; 0x40) &gt;&gt; 6;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    pthread_mutex_lock(&amp;<a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a>);</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 18; i++) {</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;      <span class="comment">// printf(&quot;%d &quot;, channels_[i]);</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      <a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a4e7ed72b0ccac4c7b9c209145ea4b01b">channel_data</a>[i] = channels_[i];</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    }</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="comment">// printf(&quot;\n\n&quot;);</span></div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    pthread_mutex_unlock(&amp;<a class="code" href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a>);</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    printf(<span class="stringliteral">&quot;Bad Packet\n&quot;</span>);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  }</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;}</div><div class="ttc" id="rt__sbus_8cpp_html_a6f3dc153fb3589ec1de06f497f9c24fd"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a6f3dc153fb3589ec1de06f497f9c24fd">sbus_data_m</a></div><div class="ttdeci">pthread_mutex_t sbus_data_m</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00023">rt_sbus.cpp:23</a></div></div>
<div class="ttc" id="rt__sbus_8cpp_html_a4e7ed72b0ccac4c7b9c209145ea4b01b"><div class="ttname"><a href="../../d2/dad/rt__sbus_8cpp.html#a4e7ed72b0ccac4c7b9c209145ea4b01b">channel_data</a></div><div class="ttdeci">uint16_t channel_data[18]</div><div class="ttdef"><b>Definition:</b> <a href="../../d2/dad/rt__sbus_8cpp_source.html#l00026">rt_sbus.cpp:26</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-8" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-8-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-8-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-8-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/d95/rt__sbus_8h_a0e901a1bce4a485f80a310854215905c_icgraph.png" border="0" usemap="#d1/d95/rt__sbus_8h_a0e901a1bce4a485f80a310854215905c_icgraph" alt=""/></div>
<map name="d1/d95/rt__sbus_8h_a0e901a1bce4a485f80a310854215905c_icgraph" id="d1/d95/rt__sbus_8h_a0e901a1bce4a485f80a310854215905c_icgraph">
</map>
</div>
</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="../../dir_61bfb0b3cdda81b1b0355ba34eb3b1eb.html">dhkim</a></li><li class="navelem"><a class="el" href="../../dir_adee5b101e079090017bb4e91c628ead.html">Public_Repository</a></li><li class="navelem"><a class="el" href="../../dir_7fc07a7b97001e7b1d18e11da761e2de.html">Cheetah-Software</a></li><li class="navelem"><a class="el" href="../../dir_e69772fee2c25f3f3a3da98250dcdda2.html">robot</a></li><li class="navelem"><a class="el" href="../../dir_20818e807e73f5841d8cf65b57c69c9c.html">include</a></li><li class="navelem"><a class="el" href="../../dir_6844cdb0195786a1ce825e66a22893fa.html">rt</a></li><li class="navelem"><a class="el" href="../../d1/d95/rt__sbus_8h.html">rt_sbus.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
